package cn.com.cpic.insurance.rulecheck.core.parameter;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import cn.com.cpic.insurance.rulecheck.core.parameter.ParameterStack;

/**
 * 
 * @author 代波
 * @since 2011-8-13
 */
public class SimpleParameterStack implements ParameterStack {
	private static final long serialVersionUID = 1167636424052918867L;
	
	private final Map<String, String> map;

	public SimpleParameterStack() {
		super();
		this.map = new HashMap<String, String>();
	}

	public Iterator<String> iterator() {
		return map.keySet().iterator();
	}

	public String setValue(String parameterToken, String value) throws IllegalArgumentException {
		if (parameterToken == null)
			throw new IllegalArgumentException("参数标识不能为null");
		if (value == null)
			throw new IllegalArgumentException("参数值不能为null");

		return map.put(parameterToken, value);
	}

	public String getValue(String parameterToken) {
		return map.get(parameterToken);
	}

	public boolean contains(String parameterToken) {
		return map.containsKey(parameterToken);
	}
}
